package com.mmp.main.servlet.report;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.mmp.common.servlet.BasicServlet;
import com.mmp.main.entity.HospitalDevice;
import com.mmp.main.util.Enums;

public class ViewDevicesScrapped extends BasicServlet {

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String jpql = "select h from HospitalDevice h where h.status = " + Enums.DEVICE_STATUS.SCRAPPED.getStatus() + " order by h.deviceName";

		/*
		 * HashMap params = new HashMap();
		 * params.put(Default.REPORT_TITLE_PARAM_NAME,
		 * Enums.REPORT_TITLE.SCRAPPED_DEVICES.getReportTitle());
		 * params.put("deviceList", dbm.queryJPQL(jpql, null,
		 * HospitalDevice.class)); viewPDFReport("r1.jasper", null, params,
		 * response);
		 */

		List<HospitalDevice> devices = dbm.queryJPQL(jpql, null, HospitalDevice.class);
		if (devices == null || devices.isEmpty()) {
			announceErorrMessage(request, response, "لم يتم  تسجيل معلومات تكهين أي جهاز من خلال هذا النظام");
		} else {
			request.setAttribute("deviceList", devices);
			viewHTMLReport(request, response, "report/ViewDevicesScrapped.jsp", Enums.REPORT_TITLE.SCRAPPED_DEVICES.getReportTitle());
		}
	}
}
